import http from "../http.ts"

/**
 * 获取新闻列表
 * @param curPage 当前页码
 * @param pageSize  多少条数据c
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getNews = (curPage, pageSize) => {

    if (pageSize === 0) {
        pageSize = 10
    }
    return http.get(`/news?page=${curPage}&size=${pageSize}`, {
        msg: false,
        token: true,
        load: false
    })
}

/**
 *  获取轮播图
 * @param pageName  哪个页面 输入页面名
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getSliderImg = (pageName) => {
    return http.get("/slider_img/pageName?page=" + pageName , {
        msg: false,
        token: true,
        load: false
    })
}

/**
 * 获取最新公告
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getNewAnnouncement = () => {
    return http.get("/announcement/new", {
        msg: false,
        token: true,
        load: false
    })
}

/**
 * 根据页面名称获取菜单
 * @returns
 */
export function getMenu() {
    return http.get(`/menu/home`, {
        msg: false,
        token: true,
        load: false
    });
}

/**
 * 获取新闻详情
 * @param {string} id
 * @returns
 */
export function getNewsDe(id) {
    return http.get(`/news/getNewsDe/${id}`,{
        msg: false,
        token: true,
        load: false
    });
}